package com.wla.controller;

import com.google.gson.Gson;
import com.wla.dto.AuthorDto;
import com.wla.dto.BookDto;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @description:
 * @author: lijinze
 * @createDate: 2020/7/28
 */
@Controller
public class HelloWorld {
    @GetMapping("/hello")
    @ResponseBody
    public String hello(@ModelAttribute("a") AuthorDto authorDto,@ModelAttribute("b") BookDto bookDto) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 101);
        map.put("author", authorDto);
        map.put("book", bookDto);
        System.out.println(authorDto);
        return new Gson().toJson(map);
    }

}
